package com.bolt.auth.security.common.store;

import com.bolt.auth.security.common.properties.BoltSecurityProperties;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.security.oauth2.provider.token.TokenStore;

@Configuration
@ConditionalOnProperty(prefix = "bolt.oauth2.token.store", name = "type", havingValue = "redis")
@EnableConfigurationProperties(BoltSecurityProperties.class)
public class RedisTokenStoreConfig {
    @Bean
    public TokenStore tokenStore(RedisTemplate<String, Object> redisTemplate,BoltSecurityProperties securityProperties){
        CustomRedisTokenStore tokenStore = new CustomRedisTokenStore(redisTemplate,securityProperties);
        return tokenStore;
    }
}

 